package com.example.yin.controller;

import com.example.yin.common.R;
import com.example.yin.model.param.CategoryListParam;
import com.example.yin.model.param.CategorySaveParam;
import com.example.yin.service.BaseCategoryService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RequestMapping("/base/category")
@RestController
public class BaseCategoryController {

    @Resource
    private BaseCategoryService categoryService;

    @PostMapping("/list")
    public R list(@Validated @RequestBody CategoryListParam param) {
        return categoryService.categoryList(param);
    }

    @PostMapping("/save")
    public R save(@Validated @RequestBody CategorySaveParam param) {
        return R.success(categoryService.saveCategory(param));
    }

    @PostMapping("/delete/{id}")
    public R delete(@PathVariable Integer id) {
        return R.success(categoryService.removeById(id));
    }

}
